<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition>

        <p:dialog id="BookCreateDlg" widgetVar="BookCreateDialog" modal="true" resizable="false" appendToBody="true" header="#{bundle.CreateBookTitle}">

            <h:form id="BookCreateForm">

                <h:panelGroup id="display">
                    <p:panelGrid columns="2" rendered="#{bookController.selected != null}">

                        <p:outputLabel value="#{bundle.CreateBookLabel_bookPK_idBook}" for="bookPK_idBook" />
                        <p:inputText id="bookPK_idBook" value="#{bookController.selected.bookPK.idBook}" title="#{bundle.CreateBookTitle_bookPK_idBook}" required="true" requiredMessage="#{bundle.CreateBookRequiredMessage_bookPK_idBook}"/>

                        <p:outputLabel value="#{bundle.CreateBookLabel_name}" for="name" />
                        <p:inputText id="name" value="#{bookController.selected.name}" title="#{bundle.CreateBookTitle_name}" required="true" requiredMessage="#{bundle.CreateBookRequiredMessage_name}"/>

                        <p:outputLabel value="#{bundle.CreateBookLabel_year}" for="year" />
                        <p:inputText id="year" value="#{bookController.selected.year}" title="#{bundle.CreateBookTitle_year}" required="true" requiredMessage="#{bundle.CreateBookRequiredMessage_year}"/>

                        <p:outputLabel value="#{bundle.CreateBookLabel_author}" for="author" />
                        <p:inputText id="author" value="#{bookController.selected.author}" title="#{bundle.CreateBookTitle_author}" />

                        <p:outputLabel value="#{bundle.CreateBookLabel_location}" for="location" />
                        <p:inputText id="location" value="#{bookController.selected.location}" title="#{bundle.CreateBookTitle_location}" />

                        <p:outputLabel value="#{bundle.CreateBookLabel_knowledgeArea}" for="knowledgeArea" />
                        <p:selectOneMenu id="knowledgeArea" value="#{bookController.selected.knowledgeArea}" required="true" requiredMessage="#{bundle.EditBookRequiredMessage_knowledgeArea}">
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{knowledgeAreaController.items}"
                                           var="knowledgeAreaItem"
                                           itemValue="#{knowledgeAreaItem}"
                                           itemLabel="#{knowledgeAreaItem.name.toString()}"
                                           />
                            <f:converter binding="#{knowledgeAreaConverter}"/>
                        </p:selectOneMenu>

                        <p:outputLabel value="#{bundle.CreateBookLabel_editorial}" for="editorial" />
                        <p:selectOneMenu id="editorial" value="#{bookController.selected.editorial}" required="true" requiredMessage="#{bundle.EditBookRequiredMessage_editorial}">
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{editorialController.items}"
                                           var="editorialItem"
                                           itemValue="#{editorialItem}"
                                           itemLabel="#{editorialItem.name.toString()}"
                                           />
                            <f:converter binding="#{editorialConverter}"/>
                        </p:selectOneMenu>

                        <p:outputLabel value="#{bundle.CreateBookLabel_bookType}" for="bookType" />
                        <p:selectOneMenu id="bookType" value="#{bookController.selected.bookType}" required="true" requiredMessage="#{bundle.EditBookRequiredMessage_bookType}">
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{bookTypeController.items}"
                                           var="bookTypeItem"
                                           itemValue="#{bookTypeItem}"
                                           itemLabel="#{bookTypeItem.description.toString()}"
                                           />
                            <f:converter binding="#{bookTypeConverter}"/>
                        </p:selectOneMenu>
                    </p:panelGrid>
                    <p:commandButton actionListener="#{bookController.saveNew}" value="#{bundle.Save}" update="display,:BookListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,BookCreateDialog);"/>
                    <p:commandButton value="#{bundle.Cancel}" onclick="BookCreateDialog.hide()"/>
                </h:panelGroup>

            </h:form>

        </p:dialog>

    </ui:composition>

</html>
